// Sample Interrupt Handler void interrupt() { // RB Port Change Interrupt if(PIR1bits.ADIF == 1) // if the RB Port Change Interrupt flag is set... { Result_DAC = ReadADC(); // read the result - Place Your Code Here - INTCONbits..ADIF = 0; // clear RB Port interrupt flag } } void main (void) { // Initialize the Pic to a Known State RCONbits.IPEN = 1; /* enable interrupt priority levels */ INTCONbits.GIEH = 1; /* enable all high priority interrupts */ // Initialize the Analog to Digital Converter OpenADC(ADC_FOSC_8 & ADC_RIGHT_JUST & ADC_0_TAD, ADC_CH0 & ADC_CH1 & ADC_CH2 & ADC_INT_OFF & ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS,0b1011); // Begin Main Loop while (1) { Result_DAC = 0; // clear result SetChanADC(ADChannel); // select AD channel to read ConvertADC(); // convert AD channel } }